package com.kis.controller

import com.alibaba.fastjson.JSON
import com.kis.model.Order
import com.kis.model.ResponseData
import com.kis.service.OrderService
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RestController

/**
 * Created by wongloong on 16-12-8.
 */
@RestController
@RequestMapping("/order")
class OrderController {
    val log = LoggerFactory.getLogger(OrderController::class.java)
    @Autowired
    lateinit var orderService: OrderService

    @RequestMapping(method = arrayOf(RequestMethod.POST))
    fun addOrSave(orderJson: String): ResponseData {
        log.info("orderJson is ${orderJson}")
        return orderService.saveOrUpdate(JSON.parseObject(orderJson, Order::class.java))
    }
}